# Maintainer: Peter Budai <peterbudai at hotmail.com>

_realname=gnuplot
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.2.2
pkgrel=1
pkgdesc="Plotting package which outputs to X11, PostScript, PNG, GIF, and others (mingw-w64)"
arch=('any')
url='http://www.gnuplot.info/'
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-readline"
         "${MINGW_PACKAGE_PREFIX}-libgd"
         "${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-pango"
         "${MINGW_PACKAGE_PREFIX}-wxWidgets"
         "${MINGW_PACKAGE_PREFIX}-libcaca"
         "${MINGW_PACKAGE_PREFIX}-libcerf"
         "${MINGW_PACKAGE_PREFIX}-gnutls")
options=('strip' 'staticlibs')
source=("https://downloads.sourceforge.net/sourceforge/${_realname}/${_realname}-${pkgver}.tar.gz"
        "01-gnuplot.patch" )
sha256sums=('a416d22f02bdf3873ef82c5eb7f8e94146795811ef808e12b035ada88ef7b1a1'
            '0cb8d3814a512b6e7de90f0f35dce0b73c7bc483201327d5ebab95b81b8b2dc9')


prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-gnuplot.patch
  autoreconf -fi
}

build() {
  cd "${srcdir}"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}

  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --without-lua \
      --with-caca \
      --with-bitmap-terminals

    make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
